﻿//////////////////////////////////////////////////////////////////////////////////
//Fields

//////////////////////////////////////////////////////////////////////////////////





//////////////////////////////////////////////////////////////////////////////////
//Main
$(document).ready(function()
{


	//Event handler for Search Button Click
	$("#btn_Search").click(function()
	{
		//Call our AJAX Search function, passing it the query
		AJAX("Search", $("#searchBox").val(), function (data)
		{
			//We want to loop through each project ID that the Webservice returns
			//and create a div for it and fill it with its information

			//Split up the data and then loop through it
			$(data + ".SI").each(function (index, element)
			{
				//Creat a uniquely ID'd div and append it to the master searchResults div
				//$("<div id=result" + index + ">"+$(element).html()+"</div").appendTo("#searchResults");
				CreateDiv(index, $(element).html());
			});

		});
	});



});
//////////////////////////////////////////////////////////////////////////////////





//////////////////////////////////////////////////////////////////////////////////
//Create the search result divs
function CreateDiv(index, content)
{
	$("<div id=result" + index + "></div").appendTo("#searchResults");
	// call AJAx to get project code
	var html = "lol";
	
	//Stylize here
	if (index % 2 == 0)
	{
		$("#result" + index).addClass("darkPianoKey");
	} 
	else
	{
		$("#result" + index).addClass("lightPianoKey");
	}
	$("#result" + index).html(content);
}
//////////////////////////////////////////////////////////////////////////////////